package com.zhuss.order.processor;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import com.zhuss.bean.bo.order.order.CreatePrefundBo;
import com.zhuss.common.AbstractProcessor;
import com.zhuss.common.Processor;
import com.zhuss.exception.DzcxException;
import com.zhuss.order.db.dao.ext.PrefundDao;
import com.zhuss.order.db.entity.Prefund;


/**
 * @description: 退款返回记录创建
 * @author: zhushanshuo
 * @create: Fri Jan 15 22:17:59 CST 2021
 **/
@Component("prefundCreate")
public class PrefundCreate extends AbstractProcessor<Object, CreatePrefundBo> implements Processor<Object, CreatePrefundBo> {

    @Autowired
    private PrefundDao prefundDao;
    
    @Autowired
	@Qualifier("prefundRead")
	private PrefundRead prefundRead;
    
    
    /**
     * 校验
     */
    @Override
    public void check(CreatePrefundBo bo) throws DzcxException {
    	
    }
    
    /**
     * 操作方法
     */
    @Override
    public Object process(CreatePrefundBo param) {
    	Prefund record = new Prefund();
    	record.setOrderId(param.getOrderId());
    	record.setOrderRefundId(param.getOrderRefundId());
    	record.setAppId(param.getAppId());
    	record.setMchId(param.getMchId());
    	record.setTradeType(param.getTradeType());
    	record.setNonceStr(param.getNonceStr());
    	record.setTransactionId(param.getTransactionId());
    	record.setApplyTotalFee(param.getApplyTotalFee());
    	record.setApplyRefundFee(param.getApplyRefundFee());
    	record.setTotalFee(param.getTotalFee());
    	record.setRefundFee(param.getRefundFee());
    	record.setSettlementTotalFee(param.getSettlementTotalFee());
    	record.setSettlementRefundFee(param.getSettlementRefundFee());
    	record.setCashFee(param.getCashFee());
    	record.setCashRefundFee(param.getCashRefundFee());
    	record.setSign(param.getSign());
    	record.setReturnMsg(param.getReturnMsg());
    	record.setResultCode(param.getResultCode());
    	record.setReturnCode(param.getReturnCode());
    	record.setWxRefundId(param.getWxRefundId());
    	record.setStatus(param.getStatus());

    	
    	record.setCreatorId(param.getConcurrentUserId());
    	record.setCreator(param.getConcurrentUserName());
    	record.setCreateTime(new Date());
    	prefundDao.create(record);
    	param.setTargetId(record.getPrefundId());
        return null;
    }
    
    /**
     * 操作日志
     */
	@Override
	public Object log(CreatePrefundBo param) throws DzcxException {
    	return null;
	}
}
